<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="supda" uri="http://www.supda.com/supda_tag" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="<%=basePath%>static/lib/html5.js"></script>
<script type="text/javascript" src="<%=basePath%>static/lib/respond.min.js"></script>
<script type="text/javascript" src="<%=basePath%>static/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>static/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]--><title>系统日志</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 系统日志 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
  <div class="text-c"> 日期范围：
		<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;">
    <input type="text"  name="" id="unknown" placeholder="输入用户名、模块" style="width:250px" class="input-text">
    <button name="" onclick="ext_search();"  class="btn btn-success" type="button" id="unknown" >
    <i class="Hui-iconfont">&#xe665;</i> 搜日志</button>
  </div>
  	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
  		<span class="l">
		<supda:permissionoperate buttonGroup="banner" menuId="${menuId}"/>
		</span>
	</div>
 	<div class="mt-20">
	<table id="tb" class="table table-border table-bordered table-hover table-bg table-sort">
	</table>
	</div>
</div>
<script type="text/javascript" src="<%=basePath%>static/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="<%=basePath%>static/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="<%=basePath%>static/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="<%=basePath%>static/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="<%=basePath%>static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="<%=basePath%>static/static/h-ui/js/H-ui.js"></script> 
<script type="text/javascript" src="<%=basePath%>static/static/h-ui.admin/js/H-ui.admin.js"></script> 
<script type="text/javascript">
var tb; 
$(document).ready(function(){	
	tb = $("#tb").dataTable({    
            "bProcessing": true, // 是否显示取数据时的那个等待提示  
            //"bLengthChange": true, //改变每页显示数据数量
            "ajax":"load",
            "orderClasses":false,
            "bDestroy":true,
            "bStateSave": true,//状态保存，使用了翻页或者改变了每页显示数据数量，会保存在cookie中，下回访问时会显示上一次关闭页面时的内容
            "bAutoWidth": true,//自动宽度          
            "bServerSide": true,//这个用来指明是通过服务端来取数据  
            "fnServerParams" : function (aoData) {
                aoData.push(
                    { "name": "fuzzysearch", "value": {"value":$("#unknown").val(), "datatype":["accountName","module"], "islike":true, "isand":false }},
                    { "name": "datesearch", "value": {"datemin": $("#datemin").val(), "datemax": $("#datemax").val(), "pattern":"yyyy-MM-dd", "datatype":"operTime"}}
                );
            },
            "sAjaxSource": "<%=basePath%>log/search.shtml?now=" + new Date().getTime(),//这个是请求的地址  
            "fnServerData": retrieveData, // 获取数据的处理函数  
            //"bPaginate": false,  //是否分页。
            "paging": true, 
            "searching":false,//隐藏搜索框
            //"bFilter": false,
            "sPaginationType": "full_numbers",      //分页样式
            "bLengthChange": true, //改变每页显示数据数量  
            "bInfo": true,//页脚信息 
            "pageLength": 10,
         	 //当处理大数据时，延迟渲染数据，有效提高Datatables处理能力  
            "deferRender": true, 
            "columns": [
						{ "data": null,
						    "sTitle":"<input type='checkbox' name='' value=''>",
						    "sClass":"center",
						    "targets": 0,
						    "orderable": false,
						    "searchable": false, 
						  },
                        { "data": "id",
                          "sTitle":"ID",
                          "sClass":"center"
                        },
                        { "data": "accountName",
                        	"sTitle":"账号",
                            "sClass":"center"
                        },
                        { "data": "module",
                        	"sTitle":"模块",
                            "sClass":"center"
                        },
                        { "data": "methods",
                        	"sTitle":"方法",
                            "sClass":"center"
                         },
                        { "data": "actionTime",
                          "sTitle":"执行时间(ms)",
                           "sClass":"center"
                        },
                        { "data": "userIp",
                          "sTitle":"请求IP",
                          "sClass":"center"
                        },
                        { "data": "operTime",
                          "sTitle":"操作时间",
                          "sClass":"center"
                        },
                        { "data": "description",
                            "sTitle":"描述",
                            "sClass":"center"
                        }
                    ],
             aoColumnDefs : [ 
              { "aTargets" :　[0],
                "sClass" : "center",
                "mRender" : function(data, type, full){ return "<input type='checkbox' value='"+full.id+"' name=''>"; },
              }],    
            "lengthMenu": [
                10,15,20// 更改每页显示记录数
            ]

        });
		
		/*全选*/
		$("table thead tr th input:checkbox").on("click" , function(){
			$(this).closest("table").find("tr > td:first-child input:checkbox").prop("checked",$("table thead th input:checkbox").prop("checked"));
	    });
		
		$("#tb tbody").on( "click", "tr", function () {
			if ( $(this).hasClass("selected") ) {
				$(this).removeClass("selected");
			}
			else {
				table.$("tr.selected").removeClass("selected");
				$(this).addClass("selected");
			}		
		  } 
		);

});

function ext_search()  
{  
	tb.fnDraw();
}  

//无调整刷新当前页面数据
function refresh(){
	//$("#tb").dataTable().fnDraw(false);
	location.replace(location.href);
}


// 3个参数的名字可以随便命名,但必须是3个参数,少一个都不行  
function retrieveData(sSource,aoData, fnCallback) {  
    $.ajax({  
        url : sSource,//这个就是请求地址对应sAjaxSource  
        data : {"aoData":JSON.stringify(aoData)},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数  
        type : 'post',  
        dataType : 'json',  
        async : false,  
        success : function(result) {  
        	fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的  
        },  
        error : function(msg) {  
        }  
    });  
}  
/*用户-删除*/
function del(obj,turl){
	var id = $(obj).parents('tr').find("input[type='checkbox']").val();
	layer.confirm('确认要删除吗？',function(index){
		 $.ajax({  
		        url : turl,
		        data : {"id":id},
		        type : 'post',  
		        dataType : 'json',  
		        async : false,  
		        success : function(data) {
			        if (data=="success") {
				        $(obj).parents("tr").remove();
				    	layer.msg('已删除!',{icon:1,time:1000});
					}else if(data == "fail"){
						layer.msg('删除失败!',{icon:2,time:1000});
					}
			     },  
			    error : function(msg) {  
			        } 
		    });  
	});
	
}
</script> 

</body>
</html>
